home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60rt.lha / Vim / vim60 / syntax / jproperties.vim < prev    next >
Encoding:
Text File  |  2001-05-09  |  5.8 KB  |  149 lines

  1. " Vim syntax file
  2. " Language:    Java Properties resource file (*.properties[_*])
  3. " Maintainer:    Simon Baldwin <simonb@sco.com>
  4. " Last change:    26th Mar 2000
  5.  
  6. " =============================================================================
  7.  
  8. " Optional and tuning variables:
  9.  
  10. " jproperties_lines
  11. " -----------------
  12. "   Set a value for the sync block that we use to find long continuation lines
  13. "   in properties; the value is already large - if you have larger continuation
  14. "   sets you may need to increase it further - if not, and you find editing is
  15. "   slow, reduce the value of jproperties_lines.
  16. if !exists("jproperties_lines")
  17.     let jproperties_lines = 256
  18. endif
  19.  
  20. " jproperties_strict_syntax
  21. " -------------------------
  22. "   Most properties files assign values with "id=value" or "id:value".  But,
  23. "   strictly, the Java properties parser also allows "id value", "id", and
  24. "   even more bizarrely "=value", ":value", " value", and so on.  These latter
  25. "   ones, however, are rarely used, if ever, and handling them in the high-
  26. "   lighting can obscure errors in the more normal forms.  So, in practice
  27. "   we take special efforts to pick out only "id=value" and "id:value" forms
  28. "   by default.  If you want strict compliance, set jproperties_strict_syntax
  29. "   to non-zero (and good luck).
  30. if !exists("jproperties_strict_syntax")
  31.     let jproperties_strict_syntax = 0
  32. endif
  33.  
  34. " jproperties_show_messages
  35. " -------------------------
  36. "   If this properties file contains messages for use with MessageFormat,
  37. "   setting a non-zero value will highlight them.  Messages are of the form
  38. "   "{...}".  Highlighting doesn't go to the pains of picking apart what is
  39. "   in the format itself - just the basics for now.
  40. if !exists("jproperties_show_messages")
  41.     let jproperties_show_messages = 0
  42. endif
  43.  
  44. " =============================================================================
  45.  
  46. " For version 5.x: Clear all syntax items
  47. " For version 6.x: Quit when a syntax file was already loaded
  48. if version < 600
  49.   syntax clear
  50. elseif exists("b:current_syntax")
  51.   finish
  52. endif
  53.  
  54. " switch case sensitivity off
  55. syn case ignore
  56.  
  57. " set the block
  58. exec "syn sync lines=" . jproperties_lines
  59.  
  60. " switch between 'normal' and 'strict' syntax
  61. if jproperties_strict_syntax != 0
  62.  
  63.     " an assignment is pretty much any non-empty line at this point,
  64.     " trying to not think about continuation lines
  65.     syn match   jpropertiesAssignment    "^\s*[^[:space:]]\+.*$" contains=jpropertiesIdentifier
  66.  
  67.     " an identifier is anything not a space character, pretty much; it's
  68.     " followed by = or :, or space or tab.  Or end-of-line.
  69.     syn match   jpropertiesIdentifier    "[^=:[:space:]]*" contained nextgroup=jpropertiesDelimiter
  70.  
  71.     " treat the delimiter specially to get colours right
  72.     syn match   jpropertiesDelimiter    "\s*[=:[:space:]]\s*" contained nextgroup=jpropertiesString
  73.  
  74.     " catch the bizarre case of no identifier; a special case of delimiter
  75.     syn match   jpropertiesEmptyIdentifier    "^\s*[=:]\s*" nextgroup=jpropertiesString
  76. else
  77.  
  78.     " here an assignment is id=value or id:value, and we conveniently
  79.     " ignore continuation lines for the present
  80.     syn match   jpropertiesAssignment    "^\s*[^=:[:space:]]\+\s*[=:].*$" contains=jpropertiesIdentifier
  81.  
  82.     " an identifier is anything not a space character, pretty much; it's
  83.     " always followed by = or :, and we find it in an assignment
  84.     syn match   jpropertiesIdentifier    "[^=:[:space:]]\+" contained nextgroup=jpropertiesDelimiter
  85.  
  86.     " treat the delimiter specially to get colours right; this time the
  87.     " delimiter must contain = or :
  88.     syn match   jpropertiesDelimiter    "\s*[=:]\s*" contained nextgroup=jpropertiesString
  89. endif
  90.  
  91. " a definition is all up to the last non-\-terminated line; strictly, Java
  92. " properties tend to ignore leading whitespace on all lines of a multi-line
  93. " definition, but we don't look for that here (because it's a major hassle)
  94. syn region  jpropertiesString        start="" skip="\\$" end="$" contained contains=jpropertiesSpecialChar,jpropertiesError,jpropertiesSpecial
  95.  
  96. " {...} is a Java Message formatter - add a minimal recognition of these
  97. " if required
  98. if jproperties_show_messages != 0
  99.     syn match   jpropertiesSpecial        "{[^}]*}\{-1,\}" contained
  100.     syn match   jpropertiesSpecial        "'{" contained
  101.     syn match   jpropertiesSpecial        "''" contained
  102. endif
  103.  
  104. " \uABCD are unicode special characters
  105. syn match   jpropertiesSpecialChar    "\\u\x\{1,4}" contained
  106.  
  107. " ...and \u not followed by a hex digit is an error, though the properties
  108. " file parser won't issue an error on it, just set something wacky like zero
  109. syn match   jpropertiesError        "\\u\X\{1,4}" contained
  110. syn match   jpropertiesError        "\\u$"me=e-1 contained
  111.  
  112. " other things of note are the \t,r,n,\, and the \ preceding line end
  113. syn match   jpropertiesSpecial        "\\[trn\\]" contained
  114. syn match   jpropertiesSpecial        "\\\s" contained
  115. syn match   jpropertiesSpecial        "\\$" contained
  116.  
  117. " comments begin with # or !, and persist to end of line; put here since
  118. " they may have been caught by patterns above us
  119. syn match   jpropertiesComment        "^\s*[#!].*$" contains=jpropertiesTODO
  120. syn keyword jpropertiesTodo        TODO FIXME XXX contained
  121.  
  122. " Define the default highlighting.
  123. " For version 5.7 and earlier: only when not done already
  124. " For version 5.8 and later: only when an item doesn't have highlighting yet
  125. if version >= 508 || !exists("did_jproperties_syntax_inits")
  126.   if version < 508
  127.     let did_jproperties_syntax_inits = 1
  128.     command -nargs=+ HiLink hi link <args>
  129.   else
  130.     command -nargs=+ HiLink hi def link <args>
  131.   endif
  132.  
  133.     HiLink jpropertiesComment    Comment
  134.     HiLink jpropertiesTodo        Todo
  135.     HiLink jpropertiesIdentifier    Identifier
  136.     HiLink jpropertiesString    String
  137.     HiLink jpropertiesExtendString    String
  138.     HiLink jpropertiesCharacter    Character
  139.     HiLink jpropertiesSpecial    Special
  140.     HiLink jpropertiesSpecialChar    SpecialChar
  141.     HiLink jpropertiesError    Error
  142.  
  143.   delcommand HiLink
  144. endif
  145.  
  146. let b:current_syntax = "jproperties"
  147.  
  148. " vim:ts=8
  149.